home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Dev / ACE_Prgs.lha / lang / TinyBasic.lha / TinyBASIC.doc < prev    next >
Text File  |  1994-01-21  |  3KB  |  102 lines

  1.                 ----------------------
  2.                 Tiny BASIC Interpreter
  3.                 ----------------------
  4.  
  5. This is a simple BASIC interpreter written in ACE BASIC. It is loosely based 
  6. upon the original Dr Dobbs version and should be considered a toy version.
  7.  
  8. The language supports numeric variables and string literals. All numbers
  9. are single-precision fixed-point values.
  10.  
  11. The following commands are implemented:
  12.  
  13.     CLS
  14.     GOTO <line>
  15.     IF <expr> THEN <statement> [ELSE <statement>]
  16.     INPUT <variable>
  17.     LET <variable>=<expr>
  18.     LIST
  19.     LOAD <string-literal>
  20.     NEW
  21.     PRINT <expr> | <string-literal> [,..]
  22.     RUN
  23.     SAVE <string-literal>
  24.     STOP
  25.  
  26. where <expr> is a numeric expression, <string-literal> is a double-quote
  27. enclosed string of characters, and <line> is a program line number, where 
  28. only the integer portion of the number is used.
  29.  
  30. Multi-statements are supported by Tiny BASIC (ie: statements separated by
  31. colons).
  32.  
  33. There are only 26 variables, corresponding to the letters of the alphabet. 
  34. Although variable names can have multiple letters, names beginning with
  35. the same letter are identical variables (eg: F is the same as FRED).
  36.  
  37. Tiny BASIC supports the following intrinsic functions:
  38.  
  39.     SIN(n)
  40.     COS(n)
  41.     TAN(n)
  42.     LOG(n)
  43.     SQR(n)
  44.     FIX(n)
  45.     INT(n)
  46.     RND
  47.  
  48. where n is a number. FIX returns the integer portion of a number while
  49. INT (the same as ACE's CLNG) rounds its argument.
  50.  
  51. Operators in order of precedence are:
  52.  
  53.     ^        exponentiation
  54.     -        unary negation
  55.     * /        multiplication and division
  56.     + -        addition and subtraction
  57.     = < > <= >= <>    relational operators
  58.  
  59. Grouping terms with parentheses alters the precedence of operations.
  60.  
  61. The interpreter is slow and limited in functionality, but it's interesting to
  62. note that Tiny BASIC has some features which ACE does not:
  63.  
  64.     - run-time error messages
  65.     - division-by-zero trapping
  66.  
  67. These are much simpler to implement in a simple interpreter like TinyBASIC 
  68. but are also planned for ACE.
  69.     
  70. Error messages are as follows:
  71.  
  72.     1. Division by zero
  73.     2. Syntax error
  74.     3. Stack overflow
  75.     4. Stack underflow
  76.     5. Line out of range 1..maxlines
  77.     6. Line does not exist
  78.     7. Out of memory
  79.     8. Can't open file for writing
  80.     9. File not found
  81.  
  82. Memory allocation for program lines is dynamic so as not to hog memory 
  83. unnecessarily, however there is still a limit to the number of lines 
  84. allowed (maxlines is currently set to 1000 but this can easily be changed).
  85.     
  86. Tiny BASIC was written for two reasons: 
  87.  
  88.     - As a test of the ACE Amiga BASIC compiler (which has far more 
  89.       features than Tiny BASIC). 
  90.  
  91.     - It was a fun thing to do :-).
  92.  
  93. Although often loathe to admit it, many programmers got their start by using
  94. interpreters not much more complex than Tiny BASIC, but a quick glance at the
  95. ACE documents will show how far BASIC has come in the last several years. And
  96. it's still going strong.
  97.  
  98. Anyway, reminisce and enjoy!
  99.  
  100. David Benn
  101. February 1993
  102.